<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LINE 1 &quot;libraries\\ghc-heap\\GHC\\Exts\\Heap\\Utils.hsc&quot; #-}</span><span>
</span><span id="line-1"></span><span class="hs-pragma">{-# LANGUAGE CPP, MagicHash #-}</span><span>
</span><span id="line-2"></span><span>
</span><span id="line-3"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Exts.Heap.Utils</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-4"></span><span>    </span><span class="annot"><a href="GHC.Exts.Heap.Utils.html#dataConNames"><span class="hs-identifier">dataConNames</span></a></span><span>
</span><span id="line-5"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-6"></span><span>
</span><span id="line-7"></span><span>
</span><span id="line-8"></span><span>
</span><span id="line-9"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Prelude.html#"><span class="hs-identifier">Prelude</span></a></span><span> </span><span class="hs-comment">-- See note [Why do we import Prelude here?]</span><span>
</span><span id="line-10"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Exts.Heap.Constants.html"><span class="hs-identifier">GHC.Exts.Heap.Constants</span></a></span><span>
</span><span id="line-11"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Exts.Heap.InfoTable.html"><span class="hs-identifier">GHC.Exts.Heap.InfoTable</span></a></span><span>
</span><span id="line-12"></span><span>
</span><span id="line-13"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Char.html#"><span class="hs-identifier">Data.Char</span></a></span><span>
</span><span id="line-14"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span>
</span><span id="line-15"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Foreign.html#"><span class="hs-identifier">Foreign</span></a></span><span>
</span><span id="line-16"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.CString.html#"><span class="hs-identifier">GHC.CString</span></a></span><span>
</span><span id="line-17"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.Exts.html#"><span class="hs-identifier">GHC.Exts</span></a></span><span>
</span><span id="line-18"></span><span>
</span><span id="line-19"></span><span class="hs-comment">{- To find the string in the constructor's info table we need to consider
      the layout of info tables relative to the entry code for a closure.

      An info table can be next to the entry code for the closure, or it can
      be separate. The former (faster) is used in registerised versions of ghc,
      and the latter (portable) is for non-registerised versions.

      The diagrams below show where the string is to be found relative to
      the normal info table of the closure.

      1) Tables next to code:

         --------------
         |            |   &lt;- pointer to the start of the string
         --------------
         |            |   &lt;- the (start of the) info table structure
         |            |
         |            |
         --------------
         | entry code |
         |    ....    |

         In this case the pointer to the start of the string can be found in
         the memory location _one word before_ the first entry in the normal info
         table.

      2) Tables NOT next to code:

                                 --------------
         info table structure -&gt; |     *------------------&gt; --------------
                                 |            |             | entry code |
                                 |            |             |    ....    |
                                 --------------
         ptr to start of str -&gt;  |            |
                                 --------------

         In this case the pointer to the start of the string can be found
         in the memory location: info_table_ptr + info_table_size
-}</span><span>
</span><span id="line-58"></span><span>
</span><span id="line-59"></span><span class="hs-comment">-- Given a ptr to an 'StgInfoTable' for a data constructor</span><span>
</span><span id="line-60"></span><span class="hs-comment">-- return (Package, Module, Name)</span><span>
</span><span id="line-61"></span><span class="annot"><a href="GHC.Exts.Heap.Utils.html#dataConNames"><span class="hs-identifier hs-type">dataConNames</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Exts.Heap.InfoTable.Types.html#StgInfoTable"><span class="hs-identifier hs-type">StgInfoTable</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-62"></span><span id="dataConNames"><span class="annot"><span class="annottext">dataConNames :: Ptr StgInfoTable -&gt; IO (String, String, String)
</span><a href="GHC.Exts.Heap.Utils.html#dataConNames"><span class="hs-identifier hs-var hs-var">dataConNames</span></a></span></span><span> </span><span id="local-6989586621679058777"><span class="annot"><span class="annottext">Ptr StgInfoTable
</span><a href="#local-6989586621679058777"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-63"></span><span>    </span><span id="local-6989586621679058776"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679058776"><span class="hs-identifier hs-var">conDescAddress</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO (Ptr Word8)
</span><a href="#local-6989586621679058775"><span class="hs-identifier hs-var">getConDescAddress</span></a></span><span>
</span><span id="line-64"></span><span>    </span><span class="annot"><span class="annottext">(String, String, String) -&gt; IO (String, String, String)
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">((String, String, String) -&gt; IO (String, String, String))
-&gt; (String, String, String) -&gt; IO (String, String, String)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; (String, String, String)
</span><a href="GHC.Exts.Heap.Utils.html#parse"><span class="hs-identifier hs-var">parse</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679058776"><span class="hs-identifier hs-var">conDescAddress</span></a></span><span>
</span><span id="line-65"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-66"></span><span>    </span><span class="hs-comment">-- Retrieve the con_desc field address pointing to</span><span>
</span><span id="line-67"></span><span>    </span><span class="hs-comment">-- 'Package:Module.Name' string</span><span>
</span><span id="line-68"></span><span>    </span><span class="annot"><a href="#local-6989586621679058775"><span class="hs-identifier hs-type">getConDescAddress</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-69"></span><span>    </span><span id="local-6989586621679058775"><span class="annot"><span class="annottext">getConDescAddress :: IO (Ptr Word8)
</span><a href="#local-6989586621679058775"><span class="hs-identifier hs-var hs-var">getConDescAddress</span></a></span></span><span>
</span><span id="line-70"></span><span>
</span><span id="line-71"></span><span class="hs-pragma">{-# LINE 71 &quot;libraries\\ghc-heap\\GHC\\Exts\\Heap\\Utils.hsc&quot; #-}</span><span>
</span><span id="line-71"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-72"></span><span>        </span><span class="hs-identifier">offsetToString</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">peek</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">ptr</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">plusPtr</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">negate</span><span> </span><span class="hs-identifier">wORD_SIZE</span><span class="hs-special">)</span><span>
</span><span id="line-73"></span><span>        </span><span class="hs-identifier">pure</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">ptr</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">plusPtr</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">stdInfoTableSizeB</span><span class="hs-special">)</span><span>
</span><span id="line-74"></span><span>                    </span><span class="hs-special">`</span><span class="hs-identifier">plusPtr</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">fromIntegral</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">offsetToString</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Int32</span><span class="hs-special">)</span><span>
</span><span id="line-75"></span><span>
</span><span id="line-76"></span><span class="hs-pragma">{-# LINE 78 &quot;libraries\\ghc-heap\\GHC\\Exts\\Heap\\Utils.hsc&quot; #-}</span><span>
</span><span id="line-78"></span><span>
</span><span id="line-79"></span><span>    </span><span class="annot"><a href="#local-6989586621679058768"><span class="hs-identifier hs-type">stdInfoTableSizeW</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span>
</span><span id="line-80"></span><span>    </span><span class="hs-comment">-- The size of a standard info table varies with profiling/ticky etc,</span><span>
</span><span id="line-81"></span><span>    </span><span class="hs-comment">-- so we can't get it from Constants</span><span>
</span><span id="line-82"></span><span>    </span><span class="hs-comment">-- It must vary in sync with mkStdInfoTable</span><span>
</span><span id="line-83"></span><span>    </span><span id="local-6989586621679058768"><span class="annot"><span class="annottext">stdInfoTableSizeW :: Int
</span><a href="#local-6989586621679058768"><span class="hs-identifier hs-var hs-var">stdInfoTableSizeW</span></a></span></span><span>
</span><span id="line-84"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679058767"><span class="hs-identifier hs-var">size_fixed</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679058765"><span class="hs-identifier hs-var">size_prof</span></a></span><span>
</span><span id="line-85"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-86"></span><span>        </span><span id="local-6989586621679058767"><span class="annot"><span class="annottext">size_fixed :: Int
</span><a href="#local-6989586621679058767"><span class="hs-identifier hs-var hs-var">size_fixed</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span>  </span><span class="hs-comment">-- layout, type</span><span class="hs-cpp">
#if defined(PROFILING)
</span><span>        </span><span class="hs-identifier">size_prof</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">2</span><span class="hs-cpp">
#else
</span><span>        </span><span id="local-6989586621679058765"><span class="annot"><span class="annottext">size_prof :: Int
</span><a href="#local-6989586621679058765"><span class="hs-identifier hs-var hs-var">size_prof</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-93"></span><span>    </span><span class="annot"><a href="#local-6989586621679058769"><span class="hs-identifier hs-type">stdInfoTableSizeB</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span>
</span><span id="line-94"></span><span>    </span><span id="local-6989586621679058769"><span class="annot"><span class="annottext">stdInfoTableSizeB :: Int
</span><a href="#local-6989586621679058769"><span class="hs-identifier hs-var hs-var">stdInfoTableSizeB</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679058768"><span class="hs-identifier hs-var">stdInfoTableSizeW</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="GHC.Exts.Heap.Constants.html#wORD_SIZE"><span class="hs-identifier hs-var">wORD_SIZE</span></a></span><span>
</span><span id="line-95"></span><span>
</span><span id="line-96"></span><span class="hs-comment">-- parsing names is a little bit fiddly because we have a string in the form:</span><span>
</span><span id="line-97"></span><span class="hs-comment">-- pkg:A.B.C.foo, and we want to split it into three parts: (&quot;pkg&quot;, &quot;A.B.C&quot;, &quot;foo&quot;).</span><span>
</span><span id="line-98"></span><span class="hs-comment">-- Thus we split at the leftmost colon and the rightmost occurrence of the dot.</span><span>
</span><span id="line-99"></span><span class="hs-comment">-- It would be easier if the string was in the form pkg:A.B.C:foo, but alas</span><span>
</span><span id="line-100"></span><span class="hs-comment">-- this is not the conventional way of writing Haskell names. We stick with</span><span>
</span><span id="line-101"></span><span class="hs-comment">-- convention, even though it makes the parsing code more troublesome.</span><span>
</span><span id="line-102"></span><span class="hs-comment">-- Warning: this code assumes that the string is well formed.</span><span>
</span><span id="line-103"></span><span class="annot"><a href="GHC.Exts.Heap.Utils.html#parse"><span class="hs-identifier hs-type">parse</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-104"></span><span id="parse"><span class="annot"><span class="annottext">parse :: Ptr Word8 -&gt; (String, String, String)
</span><a href="GHC.Exts.Heap.Utils.html#parse"><span class="hs-identifier hs-var hs-var">parse</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span id="local-6989586621679058760"><span class="annot"><span class="annottext">Addr#
</span><a href="#local-6989586621679058760"><span class="hs-identifier hs-var">addr</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#not"><span class="hs-identifier hs-var">not</span></a></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Bool) -&gt; ([String] -&gt; Bool) -&gt; [String] -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(Int -&gt; Bool) -&gt; [Int] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E"><span class="hs-operator hs-var">&gt;</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([Int] -&gt; Bool) -&gt; ([String] -&gt; [Int]) -&gt; [String] -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; Int) -&gt; [String] -&gt; [Int]
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">([String] -&gt; Bool) -&gt; [String] -&gt; Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679058754"><span class="hs-identifier hs-var">p</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679058753"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679058752"><span class="hs-identifier hs-var">occ</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-105"></span><span>                     </span><span class="hs-keyword">then</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679058751"><span class="hs-identifier hs-var">input</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-106"></span><span>                     </span><span class="hs-keyword">else</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679058754"><span class="hs-identifier hs-var">p</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679058753"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679058752"><span class="hs-identifier hs-var">occ</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-107"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-108"></span><span>    </span><span id="local-6989586621679058751"><span class="annot"><span class="annottext">input :: String
</span><a href="#local-6989586621679058751"><span class="hs-identifier hs-var hs-var">input</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Addr# -&gt; String
</span><a href="../../ghc-prim/src/GHC.CString.html#unpackCStringUtf8%23"><span class="hs-identifier hs-var">unpackCStringUtf8#</span></a></span><span> </span><span class="annot"><span class="annottext">Addr#
</span><a href="#local-6989586621679058760"><span class="hs-identifier hs-var">addr</span></a></span><span>
</span><span id="line-109"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621679058754"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679058754"><span class="hs-identifier hs-var">p</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679058749"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679058749"><span class="hs-identifier hs-var">rest1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Char -&gt; Bool) -&gt; String -&gt; (String, String)
forall a. (a -&gt; Bool) -&gt; [a] -&gt; ([a], [a])
</span><a href="../../base/src/GHC.List.html#break"><span class="hs-identifier hs-var">break</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">':'</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679058751"><span class="hs-identifier hs-var">input</span></a></span><span>
</span><span id="line-110"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621679058753"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679058753"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679058752"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679058752"><span class="hs-identifier hs-var">occ</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-111"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; [String] -&gt; String
forall a. [a] -&gt; [[a]] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#intercalate"><span class="hs-identifier hs-var">intercalate</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;.&quot;</span></span><span> </span><span class="annot"><span class="annottext">([String] -&gt; String) -&gt; [String] -&gt; String
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[String] -&gt; [String]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679058745"><span class="hs-identifier hs-var">modWords</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679058744"><span class="hs-identifier hs-var">occWord</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-112"></span><span>        </span><span class="hs-keyword">where</span><span>
</span><span id="line-113"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621679058745"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679058745"><span class="hs-identifier hs-var">modWords</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679058744"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679058744"><span class="hs-identifier hs-var">occWord</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-114"></span><span>            </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">String -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679058749"><span class="hs-identifier hs-var">rest1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C"><span class="hs-operator hs-var">&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="hs-comment">--  XXXXXXXXx YUKX</span><span>
</span><span id="line-115"></span><span>                </span><span class="hs-comment">--then error &quot;getConDescAddress:parse:length rest1 &lt; 1&quot;</span><span>
</span><span id="line-116"></span><span>                </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">[String] -&gt; String -&gt; ([String], String)
</span><a href="#local-6989586621679058739"><span class="hs-identifier hs-var">parseModOcc</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-117"></span><span>                </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">[String] -&gt; String -&gt; ([String], String)
</span><a href="#local-6989586621679058739"><span class="hs-identifier hs-var">parseModOcc</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; String
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#tail"><span class="hs-identifier hs-var">tail</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679058749"><span class="hs-identifier hs-var">rest1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-118"></span><span>    </span><span class="hs-comment">-- We only look for dots if str could start with a module name,</span><span>
</span><span id="line-119"></span><span>    </span><span class="hs-comment">-- i.e. if it starts with an upper case character.</span><span>
</span><span id="line-120"></span><span>    </span><span class="hs-comment">-- Otherwise we might think that &quot;X.:-&gt;&quot; is the module name in</span><span>
</span><span id="line-121"></span><span>    </span><span class="hs-comment">-- &quot;X.:-&gt;.+&quot;, whereas actually &quot;X&quot; is the module name and</span><span>
</span><span id="line-122"></span><span>    </span><span class="hs-comment">-- &quot;:-&gt;.+&quot; is a constructor name.</span><span>
</span><span id="line-123"></span><span>    </span><span class="annot"><a href="#local-6989586621679058739"><span class="hs-identifier hs-type">parseModOcc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-124"></span><span>    </span><span id="local-6989586621679058739"><span class="annot"><span class="annottext">parseModOcc :: [String] -&gt; String -&gt; ([String], String)
</span><a href="#local-6989586621679058739"><span class="hs-identifier hs-var hs-var">parseModOcc</span></a></span></span><span> </span><span id="local-6989586621679058737"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679058737"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span id="local-6989586621679058736"><span class="annot"><span class="annottext">str :: String
</span><a href="#local-6989586621679058736"><span class="hs-identifier hs-var">str</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span id="local-6989586621679058735"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679058735"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-type">:</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>
</span><span id="line-125"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="../../base/src/GHC.Unicode.html#isUpper"><span class="hs-identifier hs-var">isUpper</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679058735"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-126"></span><span>            </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">(Char -&gt; Bool) -&gt; String -&gt; (String, String)
forall a. (a -&gt; Bool) -&gt; [a] -&gt; ([a], [a])
</span><a href="../../base/src/GHC.List.html#break"><span class="hs-identifier hs-var">break</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'.'</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679058736"><span class="hs-identifier hs-var">str</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-127"></span><span>                </span><span class="hs-special">(</span><span id="local-6989586621679058733"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679058733"><span class="hs-identifier hs-var">top</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679058737"><span class="hs-identifier hs-var">acc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679058733"><span class="hs-identifier hs-var">top</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-128"></span><span>                </span><span class="hs-special">(</span><span id="local-6989586621679058732"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679058732"><span class="hs-identifier hs-var">top</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-identifier">_</span></span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-type">:</span></a></span><span id="local-6989586621679058731"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679058731"><span class="hs-identifier hs-var">bot</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[String] -&gt; String -&gt; ([String], String)
</span><a href="#local-6989586621679058739"><span class="hs-identifier hs-var">parseModOcc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679058732"><span class="hs-identifier hs-var">top</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; [String] -&gt; [String]
forall a. a -&gt; [a] -&gt; [a]
</span><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-var">:</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679058737"><span class="hs-identifier hs-var">acc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679058731"><span class="hs-identifier hs-var">bot</span></a></span><span>
</span><span id="line-129"></span><span>    </span><span class="annot"><a href="#local-6989586621679058739"><span class="hs-identifier hs-var">parseModOcc</span></a></span><span> </span><span id="local-6989586621679058730"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679058730"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span id="local-6989586621679058729"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679058729"><span class="hs-identifier hs-var">str</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621679058730"><span class="hs-identifier hs-var">acc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679058729"><span class="hs-identifier hs-var">str</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-130"></span></pre></body></html>